package com.zyz.K_集合.Map接口一HashMap;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author: vick
 * @Date: 2025/3/30
 * @Description:
 * @version: 1.0
 */
public class Demo3 {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        //添加
        hashMap.put("001", "aa");
        hashMap.put("002", "bb");
        hashMap.put("003", "cc");
        hashMap.put("004", "dd");
        hashMap.put(null, null);
        System.out.println(hashMap);

        System.out.println("所有的key: ");
        Set keySet = hashMap.keySet();
        for (Object key : keySet) {
            System.out.println(key);
        }


        System.out.println("所有的value: ");
        Collection values = hashMap.values();
        for (Object value : values) {
            System.out.println(value);
        }

        System.out.println("所有的映射关系");
        Set entrySet = hashMap.entrySet();
        for (Object mapping : entrySet) {
            //System.out.println(mapping);
            Map.Entry entry = (Map.Entry) mapping;
            System.out.println(entry.getKey() + "->" + entry.getValue());
        }
    }
}
